<?php
/* 
	This file is Copyright Matthew Wilkinson 2009.
	
	This file is part of Oxygen.

	Oxygen is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License version 3 as published by
	the Free Software Foundation at http://www.gnu.org/licenses/gpl-3.0.html

	Oxygen is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

*/

	Final Class Log
		{
		
		private static $exceptions = Array();
		private static $debug = Array();
		private static $warning = Array();
		private static $info = Array();
		
		private static $handler = 'database';
		private static $level = 1;
		
		const _EXCEPTION = 1;
		const _DEBUG = 2;
		const _WARNING = 4;
		const _INFO = 8;
		
		
		public static function Exception($exception)
			{
			self::$exceptions[] = $exception;
			}
		
		public static function Debug($string)
			{
			self::$debug[] = Security::string($string);
			}
		
		public static function Warning($string)
			{
			self::$warning[] = Security::string($string);
			}
		
		public static function Info($string)
			{
			self::$info[] = Security::string($string);
			}
		
		
		public static function SetLevel($bitmask)
			{
			self::$level = $bitmask;
			}
		
		public static function FlushLog()
			{
			/* FINISH!!!!! */
			$time = time();
			if (($this->level & _EXCEPTION) == _EXCEPTION)
				{
				foreach ($this->exceptions as $exception)
					{
					Database::Query('INSERT INTO log SET level="exception", object="' . $exception->object . '" string="' . $exception->message . '", time="' . $time . '"');
					}
				}
			}
		
		
		}
?>